import logger from '@common/logger';

/**
 * 执行跳转头条小程序支付
 * @param {Object} param 支付的订单详情
 * @param {String} orderNumber 订单号
 * @param {String} backUrl 回调地址
 * @param {Boolean} isCodeMode 是否是取餐码模式
 */
export const invokeToutiaoPay = (param, orderNumber, backUrl, isCodeMode=false) => {
    const payParam = {
        order_id: param.order_id,
        order_token: param.order_token,
    };
    const _payParam = encodeURIComponent(JSON.stringify(payParam));
    const path = `/pages/pay/pay?payParam=${_payParam}&service=${5}&orderNumber=${orderNumber}&backUrl=${backUrl}${isCodeMode ? '&isCodeMode=' + isCodeMode : ''}`;
    logger.info('调转的链接为：', path);
    window.tt.miniProgram.navigateTo({
        url: path,
    });
};


export default invokeToutiaoPay;
